<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<!--
 * This file is a component of env.js,
 *     http://github.com/gleneivey/env-js/commits/master/README
 * a Pure JavaScript Browser Environment
 * Copyright 2009 John Resig, licensed under the MIT License
 *     http://www.opensource.org/licenses/mit-license.php
  -->

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
      lang="en" dir="ltr" id="html">
  <head>
    <title>Document for testing arbitrary-depth IFRAME nesting in env.js</title>
  </head>
  <body onload="bodyOnloadHandler();">
    <script>
        window.top.numberNestedIframeLoads += 1;
        function aPara(pId, pText, n){
            var t = document.createTextNode(pText + " " + n);
            var p = document.createElement('p');
            p.setAttribute('id', pId + n);
            p.appendChild(t);
            document.getElementsByTagName('body')[0].appendChild(p);
        }

        window.onload = function(){     aPara("pCreatedWindowOnload",
                                              "para window onload",
                                        window.top.numberNestedIframeLoads);
                                        window.top.winLoadCount += 1;     }
        function bodyOnloadHandler(){   aPara("pCreatedBodyOnload",
                                              "para body onload",
                                        window.top.numberNestedIframeLoads);
                                        window.top.bodyLoadCount += 1;    }
        function iframeOnloadHandler(){ aPara("pCreatedIframeOnload",
                                              "para iframe onload",
                                        window.top.numberNestedIframeLoads);
                                        window.top.frameLoadCount += 1;   }
    </script>

    <p>
      This document will be loaded into an IFRAME, and the following
      JavaScript finds an element in the parent document that contains
      the nesting level count, increments it, and then produces an
      identical element with the result in this document.

      <script>
        var counterAsText = window.parent.document.
          getElementById('nestingLevel').innerHTML;
        var newCount = parseInt(counterAsText) + 1;
        document.write('\x3cspan id="nestingLevel"\x3e' + newCount +
                       '\x3c/span\x3e');
      </script>
    </p>
  </body>
</html>
